package com.neusoft.resturant.service.impl;

import com.alibaba.fastjson2.util.DateUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.resturant.common.utils.PageResult;
import com.neusoft.resturant.common.utils.PageUtils;
import com.neusoft.resturant.entity.ResShop;
import com.neusoft.resturant.mapper.ResShopMapper;
import com.neusoft.resturant.service.IResShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 店铺Service业务层处理
 * 
 * @author lzx
 * @date 2023-09-27
 */
@Service
public class ResShopServiceImpl implements IResShopService
{
    @Autowired
    private ResShopMapper resShopMapper;

    /**
     * 查询店铺
     * 
     * @param id 店铺主键
     * @return 店铺
     */
    @Override
    public ResShop selectResShopById(Long id)
    {
        return resShopMapper.selectResShopById(id);
    }

    /**
     * 获取集合
     * @param resShop
     * @return
     */
    @Override
    public List<ResShop> selectResShopList(ResShop resShop) {

      return   resShopMapper.selectResShopList(resShop);
    }

    @Override
    public PageResult selectResShopList2(ResShop resShop, Integer pageNum, Integer pageSize) {
        //1、PageHelper开始分页，传入第几页和每页多少条记录两个参数
        PageHelper.startPage(pageNum, pageSize);
        //2、数据库进行查询
        List<ResShop> resShops = resShopMapper.selectResShopList(resShop);
        //3、对返回值进行判断
        if (resShops.size()==0){
            return null;
        }
        //4、对查询的结果进行封装
        PageInfo<ResShop> thumbupPageInfo = new PageInfo<>(resShops);
        PageResult pageResult = PageUtils.getPageResult(thumbupPageInfo);

        return pageResult;

    }
}
